package dao

import (
	"MobilePackagePromotions/internal/model"

	"context"
	"fmt"
	"github.com/go-kratos/kratos/pkg/database/sql"
	"github.com/go-kratos/kratos/pkg/log"
)

func (d *dao) GetPromotions(c context.Context, id int) (promotions *model.Promotions, err error) {
	querySql := fmt.Sprintf("SELECT * FROM `promotions` WHERE `id`=?;")

	promotions = new(model.Promotions)
	err = d.db.QueryRow(c, querySql, id).Scan(&promotions.ID, &promotions.PromotionsContent, &promotions.CreateTime, &promotions.Status)
	if err != nil && err != sql.ErrNoRows {
		log.Error("d.QueryRow error(%v)", err)
		return
	}
	return
}
